﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ERP_InStoreEdit.aspx.cs" Inherits="CRM_Store_ERP_InStoreEdit" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <link href="../css/PageStyle.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="../JavaScript/Common.js"></script>
    <title></title>
    <script type="text/javascript" >
        function AfterOperate(str, ObjId) {
            Ext.net.DirectMethods.GetBasicInfo(str, ObjId);
        }

        function OnAdd_Click() {
            var grid = gridPanel_listdata;
            var rowIndex = grid.addRecord();
            grid.getView().focusRow(rowIndex);
            grid.startEditing(rowIndex, 1);
        }

        function OnDel_Click() {
            var grid = gridPanel_listdata;
            if (!grid.hasSelection()) {
                Ext.Msg.alert("系统提示", "请选择一条记录!");
                return;
            }
            Ext.Msg.confirm("确认框", "是否确认删除？", function (btn) {
                if (btn == "yes") {
                    var record = gridPanel_listdata.selModel.getSelected();
                    Ext.net.DirectMethods.RemoveItem(record.data.ItemlId);
                }
            });
        }


        function SaveClick(type) {
            if (FieldEmptyCheck2Trim(formPanel))
            {
                if (gridPanel_listdata.store.data.length > 0) {
                    Ext.net.DirectMethods.SaveData(type);
                }
                else
                    Ext.Msg.alert("系统提示", "请至少添加一条商品!");
            }
        }

        function Onextcomb_Supplier_BeforeSelect() {
            if (extcomb_SupplyId.mimicing == false)
                return false;
        }
        function SearchOperate() {
            Store_Supply.reload();
        }
        function SearchOperate2() {
            if (extcomb_SupplyId.text == "") {
                Store_Supply.reload();
            }
        }

    </script>
</head>
<body>
    <ext:ResourceManager ID="ResourceManager1" runat="server" AjaxViewStateMode="Enabled" />
    <form id="form1" runat="server">
    <ext:Viewport ID="Viewport1" runat="server" Layout="FitLayout" >
        <Content>
            <ext:Panel runat="server" Border="false" Layout="RowLayout">
                <TopBar>
                    <ext:Toolbar runat="server">
                        <Items>
                            <ext:Button ID="extBtn_Save" runat="server" Text="保存" Icon="Accept">
                                <Listeners>
                                    <Click Handler="SaveClick(0);" />
                                </Listeners>
                            </ext:Button>
                            <ext:Button ID="extBtn_SubmitInfo" runat="server" Text="提交" Icon="FolderGo">
                                <Listeners>
                                    <Click Handler="SaveClick(1);" />
                                </Listeners>
                            </ext:Button>
                            <ext:Button ID="extBtn_CheckInfo" runat="server" Text="审核" Icon="Lock">
                                <Listeners>
                                    <Click Handler="SaveClick(2);" />
                                </Listeners>
                            </ext:Button>
                            <ext:Button ID="extBtn_Exit" runat="server" Text="退出" Icon="Cancel">
                                <Listeners>
                                    <Click Fn="closeCurrTab" />
                                </Listeners>
                            </ext:Button>
                            <ext:ToolbarFill ID="ToolbarFill3" runat="server" />
                            <%--<ext:Button ID="extBtn_Print" runat="server" Text="打印" Icon="Printer">
                                <DirectEvents>
                                    <Click OnEvent="OnBtnPrintClick">
                                    </Click>
                                </DirectEvents>
                            </ext:Button>--%>
                        </Items>
                    </ext:Toolbar>
                </TopBar>
                <Items>
                    <ext:Panel ID="formPanel" runat="server" Border="false" Padding="10" Height="102" Layout="ColumnLayout" >
                        <Items>
                            <ext:Container runat="server" Layout="FormLayout" LabelAlign="Right" ColumnWidth="0.33">
                                <Items>
                                    <ext:TextField runat="server" ID="exttxtf_ExportBillNo" FieldLabel="入库单号" ReadOnly="true" AnchorHorizontal="0.95" />
                                    <ext:TextField runat="server" ID="exttxtf_ReceiptNo" FieldLabel="发票号" AnchorHorizontal="0.95" />
                                    <ext:ComboBox ID="extcomb_StoreRoomId" runat="server" FieldLabel="申请库房"
                                        AnchorHorizontal="0.95" Editable="false" ValueField="STOREROOM_ID" DisplayField="STOREROOM_NAME"
                                        TabIndex="2">
                                        <Store>
                                            <ext:Store ID="Store_Rome" runat="server">
                                                <Reader>
                                                    <ext:JsonReader IDProperty="STOREROOM_ID">
                                                        <Fields>
                                                            <ext:RecordField Name="STOREROOM_ID" />
                                                            <ext:RecordField Name="STOREROOM_NAME" />
                                                        </Fields>
                                                    </ext:JsonReader>
                                                </Reader>
                                            </ext:Store>
                                        </Store>
                                    </ext:ComboBox>
                                </Items>
                            </ext:Container>
                            <ext:Container runat="server" Layout="FormLayout" LabelAlign="Right" ColumnWidth="0.33">
                                <Items>
                                    <ext:TextField runat="server" ID="exttxtf_InUserName" FieldLabel="定制人" ReadOnly="true" AnchorHorizontal="0.95" />
                                    <ext:Hidden runat="server" ID="exthidn_InUser" />
                                    <ext:DateField runat="server" ID="extdate_ReceiptDate" FieldLabel="发票时间" AnchorHorizontal="0.95" />
                                    <ext:ComboBox runat="server" ID="extcomb_SupplyId" AllowBlank="false" FieldLabel="供货商"
                                        DisplayField="SupplyName" ValueField="SupplyID" TypeAhead="false" LoadingText="Searching..."
                                        TriggerAction="All" ForceSelection="false" SelectOnFocus="true" EmptyText="请输入汉字或拼音简码"
                                        Mode="Remote" ItemSelector="div.search-item" MinChars="1" ListWidth="600" TabIndex="10"
                                        AnchorHorizontal="0.95" PageSize="10" >
                                        <Template ID="Template1" runat="server">
                                            <Html>
                                            <table width="100%" style="background-color: #f0f0f0; font-size: small; font-weight: bold">
                                                <tr>
                                                    <td style="width: 33%;">供货商</td>
                                                    <td style="width: 33%;">拼音码</td>
                                                    <td style="width: 33%;">地址</td>
                                                </tr>
                                            </table>
                                            <tpl for=".">
                                                <div class="search-item">
                                                    <table width="100%">
                                                        <tr>
                                                            <td style="width:33%; ">{SupplyName}</td>
                                                            <td style="width:33%; ">{Spell}</td>
                                                            <td style="width:33%; ">{Address}</td>
                                                        </tr>
                                                    </table>
                                                </div>
                                            </tpl>
                                            </Html>
                                        </Template>
                                        <Listeners>
                                            <Change Fn="SearchOperate" />
                                            <KeyDown Fn="SearchOperate2" />
                                            <Expand Fn="SearchOperate" />
                                            <BeforeSelect Fn="Onextcomb_Supplier_BeforeSelect" />
                                        </Listeners>
                                        <Store>
                                            <ext:Store runat="server" ID="Store_Supply" OnRefreshData="StoreSupply_Refresh" RemotePaging="true">
                                                <Reader>
                                                    <ext:JsonReader IDProperty="SupplyID">
                                                        <Fields>
                                                            <ext:RecordField Name="SupplyID" />
                                                            <ext:RecordField Name="SupplyName" />
                                                            <ext:RecordField Name="Spell" />
                                                            <ext:RecordField Name="Address" />
                                                        </Fields>
                                                    </ext:JsonReader>
                                                </Reader>
                                            </ext:Store>
                                        </Store>
                                    </ext:ComboBox>
                                </Items>
                            </ext:Container>
                            <ext:Container runat="server" Layout="FormLayout" LabelAlign="Right" ColumnWidth="0.33">
                                <Items>
                                    <ext:TextField runat="server" ID="exttxtf_InDate" FieldLabel="入库时间" ReadOnly="true" AnchorHorizontal="0.95" />
                                    <ext:NumberField runat="server" ID="extnumf_ReceiptMoney" FieldLabel="发票金额" DecimalPrecision="2" AnchorHorizontal="0.95" />
                                    <ext:TextField runat="server" ID="exttxtf_Remark" FieldLabel="备注" MaxLength="400" AnchorHorizontal="0.95" />
                                </Items>
                            </ext:Container>
                        </Items>
                    </ext:Panel>
                    <ext:GridPanel runat="server" ID="gridPanel_listdata" RowHeight="1" BodyStyle="border-width:1 0 0 0;" AutoScroll="true" TrackMouseOver="true" StripeRows="true" ClicksToEdit="1" >
                        <TopBar>
                            <ext:Toolbar runat="server">
                                <Items>
                                    <ext:ToolbarFill runat="server" />
                                    <ext:FileUploadField ID="extFuf_ImportExcel" runat="server" ButtonOnly="true" ButtonText="导入Excel" Icon="PageExcel" >
                                        <Listeners>
                                            <FileSelected Handler="Ext.net.DirectMethods.ImportExcel();" />
                                        </Listeners>
                                    </ext:FileUploadField>
                                    <ext:Button ID="extBtn_AddItem" runat="server" Text="添加" Icon="Add" TabIndex="12">
                                        <DirectEvents>
                                            <Click OnEvent="extBtn_AddItem_Click" />
                                        </DirectEvents>
                                    </ext:Button>
                                    <ext:Button ID="extBtn_DeleteItem" runat="server" Text="删除" Icon="Delete" TabIndex="12">
                                        <Listeners>
                                            <Click Fn="OnDel_Click" />
                                        </Listeners>
                                    </ext:Button>
                                </Items>
                            </ext:Toolbar>
                        </TopBar>
                        <ColumnModel>
                            <Columns>
                                <ext:RowNumbererColumn Header="<center>序号</center>" Width="35" />
                                <ext:Column Header="<center>商品名称</center>" Width="180" DataIndex="CargoName" />
                                <ext:Column Header="<center>规格</center>" Width="100" DataIndex="Spec" />
                                <ext:Column Header="<center>型号</center>" Width="100" DataIndex="Version" />
                                <ext:Column Header="<center>厂家</center>" Width="120" DataIndex="ProduceName" />
                                <ext:Column Header="<center>产地</center>" Width="120" DataIndex="Area" />
                                <ext:Column Header="<center>批号</center>" Width="120" DataIndex="BatchNo" />
                                <ext:DateColumn Header="<center>生产日期</center>" Width="120" DataIndex="ProduceDate" Format="Y-m-d" />
                                <ext:DateColumn Header="<center>消毒日期</center>" Width="120" DataIndex="DisinfectionDate" Format="Y-m-d" />
                                <ext:DateColumn Header="<center>生产失效日期</center>" Width="120" DataIndex="ExpiryDate" Format="Y-m-d" />
                                <ext:DateColumn Header="<center>消毒失效日期</center>" Width="120" DataIndex="AsepticDate" Format="Y-m-d" />
                                <ext:Column Header="<center>数量</center>" Width="80" DataIndex="Count" />
                                <ext:NumberColumn Header="<center>购入价</center>" Width="120" DataIndex="Supplyprice" />
                                <ext:NumberColumn Header="<center>总金额</center>" Width="120" DataIndex="TotalPrice" />
                            </Columns>
                        </ColumnModel>
                        <Store>
                            <ext:Store runat="server" ID="Store1" >
                                <Reader>
                                    <ext:JsonReader IDProperty="ItemlId">
                                        <Fields>
                                            <ext:RecordField Name="ItemlId" Type="Int" />
                                            <ext:RecordField Name="DExportBillId" Type="Int" />
                                            <ext:RecordField Name="OrderId" Type="Int" />
                                            <ext:RecordField Name="Count" Type="Int" />
                                            <ext:RecordField Name="DetailId" Type="Int" />
                                            <ext:RecordField Name="BatchNo" />
                                            <ext:RecordField Name="ProduceDate" Type="Date" />
                                            <ext:RecordField Name="DisinfectionDate" Type="Date" />
                                            <ext:RecordField Name="ExpiryDate" Type="Date" />
                                            <ext:RecordField Name="AsepticDate" Type="Date" />
                                            <ext:RecordField Name="Supplyprice" Type="Float" />
                                            <ext:RecordField Name="TotalPrice" Type="Float" />
                                            <ext:RecordField Name="CargoId" Type="Int" />
                                            <ext:RecordField Name="CargoName" />
                                            <ext:RecordField Name="ByName" />
                                            <ext:RecordField Name="CargoCode" />
                                            <ext:RecordField Name="Spec" />
                                            <ext:RecordField Name="Version" />
                                            <ext:RecordField Name="ProduceName" />
                                            <ext:RecordField Name="Area" />
                                            <ext:RecordField Name="Unit" />
                                            <ext:RecordField Name="SupplyName" />
                                            <ext:RecordField Name="TypeName" />
                                            <ext:RecordField Name="UseNAME" />
                                        </Fields>
                                    </ext:JsonReader>
                                </Reader>
                            </ext:Store>
                        </Store>
                        <SelectionModel>
                            <ext:RowSelectionModel runat="server" SingleSelect="true" />
                        </SelectionModel>
                        <BottomBar>
                            <ext:PagingToolbar runat="server" ID="PagingToolbar1" PageSize="20" DisplayInfo="true"
                                Height="25" DisplayMsg="显示{0} - {1},共{2}条" EmptyMsg="没有可显示的记录" StateID="Store1" />
                        </BottomBar>
                    </ext:GridPanel>
                </Items>
            </ext:Panel>
        </Content>
    </ext:Viewport>
    </form>
</body>
</html>
